package com.lottery.material.service.portal.competition.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lottery.material.common.Constants;
import com.lottery.material.dao.article.CompetitionInfoMapper;
import com.lottery.material.pojo.article.CompetitionInfo;
import com.lottery.material.pojo.page.PageData;
import com.lottery.material.service.portal.competition.CompetitionInfoService;
import com.lottery.material.util.AssertUtil;
import com.lottery.material.util.CalendarUtil;
import com.lottery.material.util.Const;
import com.lottery.material.util.HttpClientUtil;
import com.lottery.material.vo.portal.competition.CompetitionArticleVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author:houjie
 * @Description: 赛事接口实现类
 * @Date:Create in 2019/4/10 14:23
 */
@Service
@Slf4j
public class CompetitionInfoServiceImpl implements CompetitionInfoService{

    @Autowired
    CompetitionInfoMapper competitionInfoMapper;

    @Override
    public List<CompetitionInfo> findAllByCompetitionTypeAndStatePage(Map<String,Object> paramMap) {
        paramMap.put("indexStart", Const.PORTAL_PAGE*(Integer.parseInt(paramMap.get("page").toString())-1));
        paramMap.put("pageTotal",Const.PORTAL_PAGE);
        return competitionInfoMapper.findAllByCompetitionTypeAndStatePage(paramMap);
    }

    @Override
    public CompetitionInfo findByCompetitionTypeAndOpenId(PageData pd) {
        return competitionInfoMapper.findByCompetitionTypeAndOpenId(pd);
    }

    @Override
    public List<CompetitionArticleVo> findCompetitionArticleVoByArticleId(Integer articleId) {
        return competitionInfoMapper.findCompetitionArticleVoByArticleId(articleId);
    }

    /**
     * description: 根据赛事id查询
     * author sunny
     * createDate 2019-04-18 下午 8:35
     * @param CompetitionId
     * @return
     */
    @Override
    public CompetitionInfo findByCompetitionId(Integer CompetitionId) {
        return competitionInfoMapper.selectByPrimaryKey(CompetitionId);
    }

}
